package org.picommo.common;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

/**
 * Signifies a certain type of cell in the PicoMMO world.. for example grass
 * or water. Is normally read from an XML config file.
 * 
 * @author Magnus Wolffelt
 */
@Root
public class CellType {

	@Attribute
	private final String identifier;
	
	@Attribute
	private final boolean isPassable;
	
	@Element
	private final Color primaryColor;


	public CellType(String identifier, boolean isPassable, Color primaryColor) {
		super();
		this.identifier = identifier;
		this.isPassable = isPassable;
		this.primaryColor = primaryColor;
	}


	public CellType() {
		this(null, false, Color.BLACK);
	}

	public boolean isPassable() {
		return isPassable;
	}
	
	public String getName() {
		return identifier;
	}
	
	public Color getPrimaryColor() {
		return primaryColor;
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof CellType)) {
			return false;
		}
		
		CellType otherType = (CellType)obj;
		
		return otherType.getName().equals(getName()) && otherType.isPassable() == isPassable();
	}
}
